import HttpService from '../../app/services/httpService.js';

class UserService extends HttpService {
    constructor($http, $q){
        super($http, $q)

        this.URL = this.baseUrl();

        this.OBJ = {
        	CheckLoginUrl: this.URL + '/public/checklogin?access-token=',
            LogoutUrl: this.URL + '/public/logout?access-token=',
            LoginUrl: this.URL + '/public/login',
            FindpassUrl: this.URL + '/public/findpass',
            ChangepwdUrl: this.URL + '/user/changepwd',
            RegisterUrl: this.URL + '/public/register',
            VerifyphoneUrl: this.URL + '/public/verifyphone',
            SmsaddUrl: this.URL + '/service/addcompanysms',
            MaterialListsUrl: this.URL + '/material/lists',
            UnbindUrl: this.URL + '/material/del?name=',
            MaterialAddUrl: this.URL + '/material/add',
            DistributeMaterialUrl: this.URL + '/material/bindchange'
        }

    }

    /* 检查登录状态 */
    postCheckLogin(search) {
        return this.getRequest(this.OBJ.CheckLoginUrl, '', search);
    }

    /* 用户登出 */
    postLogout(search) {
        return this.getRequest(this.OBJ.LogoutUrl, '', search);
    }

    /* 用户登录 */
    postLogin(params) {
        return this.postRequest(this.OBJ.LoginUrl, params);
    }

    /* 忘记密码 */
    postFindpass(params) {
        return this.postRequest(this.OBJ.FindpassUrl, params);
    }

    /* 修改密码 */
    postChangepwd(params, headers) {
        return this.postRequest(this.OBJ.ChangepwdUrl, params, headers);
    }

    /* 用户注册 */
    postRegister(params) {
        return this.postRequest(this.OBJ.RegisterUrl, params);
    }

    /* 获取手机验证码 */
    postVerifyphone(params) {
        return this.postRequest(this.OBJ.VerifyphoneUrl, params);
    }

    /* 给机构充值短信 */
    postSmsadd(params, headers) {
        return this.postRequest(this.OBJ.SmsaddUrl, params, headers);
    }

    /* 计时设备list */
    getMaterialLists(headers) {
        return this.getRequest(this.OBJ.MaterialListsUrl, headers, '');
    }

    /* 解绑设备 */
    getUnbind(headers, search) {
        return this.getRequest(this.OBJ.UnbindUrl, headers, search);
    }

    /* 添加设备 */
    postMaterialAdd(params, headers) {
        return this.postRequest(this.OBJ.MaterialAddUrl, params, headers);
    }

    /* 分配设备给机构 */
    postDistributeMaterial(params, headers) {
        return this.postRequest(this.OBJ.DistributeMaterialUrl, params, headers);
    }
}

export default UserService;